<?php

namespace App\V3\V3_2_6\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;

class BuyStorageSpaceModel extends Model
{


    use HasFactory;
    protected $table   = 'buy_storage_space';
    protected $dateFormat = 'U';//这个时间字段被为被格式化为UNIX 时间戳的形式存储
    //toArray 时间转换问题
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    static public function add($data){

        return BuyStorageSpaceModel::insertGetId($data);
    }

    static public function edit($data){

        return BuyStorageSpaceModel::where(['id'=>$data['id']])->update($data);
    }

    static public function list(){

        return BuyStorageSpaceModel::orderBy('set_space','asc')->get();
    }
}
